<template>
    <div class="wrapper">
        <el-table class="table" :data="workDoneSList" border>
            <el-table-column label="发布日期" prop="dateStart"></el-table-column>
            <el-table-column label="截至日期" prop="dateFinish"></el-table-column>
            <el-table-column label="作业名称" prop="title"></el-table-column>
            <el-table-column label="发布人" prop="author"></el-table-column>
            <el-table-column label="操作">
                <template scope="scope">
                    <el-button size="small" type="success" v-on:click="start(scope.$index, scope.row)">修改作业</el-button>
                </template>           
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    export default{
        created: function() {
            this.$http({
                method: 'POST',
                url: '/api/student/WorkDoneSList',
                headers: {
                    'Authorization': 'Bearer '+ localStorage.token
                }
            }).then( response => {
                if(response.data.errno == 200) {
                    this.workDoneSList = response.data.data
                } 
                else {
                    this.$notify({
                        title: '未知错误！',
                        type: 'success',
                        offset: 100
                    })
                }
            })
        },
        data: function() {
            return {
                workDoneSList: []
            }
        },
        methods: {
            start(index, row) {
                this.$router.push({ name: 'paperS', params: { workId: row.id, mark: 0 } })
            },
        }
    }
</script>

<style scoped>
    .table {
        width: 70%;
        margin: 0 auto;
        position: relative;
        top: 100px;
        text-align: left;
    } 
</style>